#include "Menu.h"
#include <iostream>  
#include <fstream>  //SS-A1, MF-A2, BA-A3
//additional includes


using namespace std;

Menu::Menu()
{
}

void Menu::display_main_menu() const 
{
	cout << "\nHere is the MAIN MENU\n"; // BA A3
	cout << " Type 1 for Info\n";  // BA A3
	cout << " Type 2 for Read\n";  // BA A3
	cout << " Type 3 for Show\n";  // BA A3
	cout << " Type 4 for Find\n";  // BA A3
	cout << " Type 5 for Update\n";  // BA A3
	cout << " Type 6 for Exit\n\n";  // BA A3
}
void Menu::display_info() const
{
	cout << "Here is the Info requested \n";//display Project Part I, team name and team members
	cout << "----------------Project Part I----------------"<<endl;//added MF A2
	cout << "Team Name   : 						 Blue-ABC-2"<<endl;//added MF A2
	cout << "Team Members: 						           "<<endl;//added MF A2
	cout << "           		            Matthew Fischer"<<endl;//added MF A2
	cout << "           		            Binayak Acharya"<<endl;//added MF A2
	cout << "           		              Sidik Soleman"<<endl;//added MF A2
	cout << "----------------------------------------------"<<endl;//added MF A2
}

void Menu::read()
{
	cout << "Read file name then read store data \n";
	//start part SS-A1 : read and store customer data from file to memory (all added in this part : SS-A1)
	ifstream cust_input; //SS-A1 reading customer data
	int ndata, addr_num, addr_zip, cust_id; //SS-A1 
	string cust_name, addr_name; //SS-A1 
	custs.clear(); //clearing containers before reading SS-A1 
	cust_input.open("../Sample_Data/Cust.dat");  //SS-A1 
	if(!cust_input) cerr<<"Error : no such file input\n";  //SS-A1 
	cust_input>>ndata;  //SS-A1 
	for(int i=0;i<ndata;++i)  //SS-A1 
	{
		cust_input>>cust_id; //SS-A1 
		cust_input>>cust_name; //SS-A1 
		cust_input>>addr_num; //SS-A1 
		cust_input>>addr_name; //SS-A1 
		cust_input>>addr_zip; //SS-A1 
		custs.push_back(Customer(cust_id,cust_name,Address(addr_num, addr_name, addr_zip))); //SS-A1 
	}
	cust_input.close(); //end SS-A1
	//start part MF-A2
	ifstream cartFile("../Sample_Data/carts.dat", ifstream::in); //added MF A2
	
	int num_cart; //added MF A2
	cartFile >> num_cart;
	for(int i=0 ; i<num_cart;++i)
	{
		int cart_Id; //added MF A2
		int cust_Id; //added MF A2
		int year_row; //added MF A2
		int month_row; //added MF A2
		int day_row; //added MF A2
		
		cartFile >> cart_Id >> cust_Id >> year_row >> month_row >> day_row; //added MF A2
		Date x(year_row,Date::Month(month_row),day_row); //added MF A2
		Cart a(cart_Id,cust_Id,x); //added MF A2
		carts.push_back(a); //added MF A2
	}
	
	cartFile >> num_cart;
	for(int i=0 ; i<num_cart;++i)//added MF A2
	{
		int cartId;//added MF A2
		int custId;//added MF A2
		int prodId;//added MF A2
		int prodqty;//added MF A2
		
		
		cartFile >> cartId >> custId >> prodId >> prodqty;//added MF A2
		Cart_item info(cartId,custId,prodId,prodqty);//added MF A2
		cart_items.push_back(info); //added MF A2
	}
	//end MF-A2
	//start part BA-A3
	ifstream catprd("../Sample_Data/catprd.dat");    // BA A3
	
	int numcat;    // BA A3
	catprd >> numcat;    // BA A3
	for (int i=0; i<numcat; ++i) // BA A3
	{
		int catid; // BA A3
		string catname; // BA A3
		catprd >> catid >> catname; // BA A3

		Category c(catid, catname);// BA A3

		cats.push_back(c); // BA A3
	}

	int numprod; // BA A3
	catprd >> numprod; // BA A3
	for ( int i=0; i < numprod; ++i) // BA A3
	{
		int prodid; // BA A3
		int catid; // BA A3
		string prodname; // BA A3
		double prodprice; // BA A3
		catprd >> prodid >> catid >> prodname >> prodprice; // BA A3

		Product a(prodid, catid, prodname, prodprice); // BA A3

		prods.push_back(a); // BA A3
	}
	//end BA-A3
	
}
void Menu::show() const 
{
	cout << "Show queries \n";
		
}
void Menu::find() const 
{
	cout << "Find queries \n";
}
void Menu::update()  
{
	cout << "Update queries \n";
}